<? 
	include('base.php');
	User::protect();
	
	if ($_POST['submit']) { 
		// add news entry
		$uo2 = User::add($_POST);				
		if (!db::isError($uo2)) {
			header('Location: admin_user_edit.php?id=' . $uo2->getID());
			exit;
		}
	}
	$calendar = true;
	$section = 'admin_users';
	$page_title = 'Add User';
	include('layout/header.php');
?>

<div id="breadcrumb">
	<a href="index.php">Audition&nbsp;&#62;</a>&nbsp;<a href="admin.php">Administer Audition&nbsp;&#62;</a>&nbsp;<a href="admin_users.php">Users&nbsp;&#62;</a>&nbsp;Add User
</div>

<? 

$u = User::getCurrent();
if (!$u->isAdmin()) { 
	Error::outputDialog('Return to Main Menu', 'index.php', 'Only an administrator may access administrator options.');
} else { 

	if (db::isError($uo2)) {
		$uo2->outputList();
	}
	
	?>
	<h1>add user:</h1>
	<div class="inset">
	<form id="edit_entry" action="<?=$PHP_SELF?>" method="post">
	<table border="0" cellspacing="0" cellpadding="0" class="edit-form">
	<tr>
		<td width="50%"><strong>Username</strong><br/><input type="text" name="username" value="<?=$_POST['username']?>" class="text"></td>
		<td width="50%"><strong>Email Address</strong><br/><input type="text" name="email" value="<?=$_POST['email']?>" class="text"></td>
	</tr>
	<tr>
		<td width="50%"><strong>Password</strong><br/><input type="password" name="password" value="" class="text"></td>
		<td width="50%"><strong>Password (Confirm)</strong><br/><input type="password" name="password_confirm" value="" class="text"></td>
	</tr>
	<tr>
		<td><strong>Date of Birth (<a style="vertical-align: middle" href="javascript:void(0)" onclick="popUpCalendar(this, document.getElementById('date'), '<?=DATE_JS_CALENDAR?>')">Calendar</a>)</strong><br/>
			<input type="text" name="birthdate" id="date" value="<?=$_POST['birthdate']?>" class="text"></td>
		<td><strong>User Level</strong>
		<select name="level">
			<option value="USER"<? if ($_POST['level'] == 'USER') { ?> selected<? } ?>>Regular User</option>
			<option value="ADMIN"<? if ($_POST['level'] == 'ADMIN') { ?> selected<? } ?>>Administrator</option>
		</select>
		</td>
	</tr>
	<tr>
		<td><strong>Last&nbsp;Name:<br/><input type="text" name="lastname" value="<?=$_POST['lastname']?>" class="text"></td>
		<td><strong>First Name</strong><br/><input type="text" name="firstname" value="<?=$_POST['firstname']?>" class="text"></td>
	</tr>
	</table>
		
	<div class="edit-form">
		<input type="submit" value="Add User" name="submit" class="button">
		<input type="button" value="Exit Without Adding" name="preview" onclick="location.href='admin_users.php'; return false" class="button">
	</div>
<? } ?>

<? include('layout/footer.php'); ?>
